package com.example.leepong.Game.Shapes;

/**
 * Created by Ichigo on 28/02/14.
 */
public class Rectangle {
    public int Width;
    public int Height;
    public Coordinates Coord;

    public float Left() {
        return Coord.X;
    }

    public float Top() {
        return Coord.Y;
    }

    public float Right() {
        return Coord.X + Width;
    }

    public float Bottom() {
        return Coord.Y + Height;
    }

    public float CenterX() {

        return Coord.X + (Width / 2);
    }

    public float CenterY() {
        return Coord.Y + (Height / 2);
    }

    public void setBottom(float value) {
        Coord.Y = value - Height;
    }

    public void setCenterX(float value) {
        Coord.X = value - (Width / 2);
    }

    public void setCenterY(float value) {
        Coord.Y = value - (Height / 2);
    }

    public Rectangle() {
        this.Coord = new Coordinates();
    }

    public Rectangle(float x, float y, int width, int height) {
        this();
        this.Coord.X = x;
        this.Coord.Y = y;
        this.Width = width;
        this.Height = height;
    }

    public Rectangle(Rectangle rectangle) {
        this(rectangle.Coord.X, rectangle.Coord.Y, rectangle.Width, rectangle.Height);
    }

    public boolean Contains(Coordinates coord) {
        return this.Contains(coord.X, coord.Y);
    }

    public boolean Contains(float x, float y) {
        return this.Coord.X <= x && x < this.Coord.X + this.Width && this.Coord.Y <= y && y < this.Coord.Y + this.Height;
    }

    public boolean IntersectsWith(Rectangle rect) {
        return rect.Coord.X < this.Coord.X + this.Width && this.Coord.X < rect.Coord.X + rect.Width && rect.Coord.Y < this.Coord.Y + this.Height && this.Coord.Y < rect.Coord.Y + rect.Height;
    }

}
